package org.libarae.client;

import java.util.Vector;

import org.libarae.client.threads.FeaturedTabThread;
import org.libarae.client.threads.HasFeaturedTabThread;
import org.libarae.communication.common.Book;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FeaturedBookPanel.java
 *
 * Created on Mar 30, 2011, 8:10:13 PM
 */

/**
 *
 * @author Casey, Ben
 */
@SuppressWarnings("serial")
public class FeaturedBookPanel extends javax.swing.JPanel implements HasFeaturedTabThread {

    @SuppressWarnings("unused")
	private Vector<Book> mRecentBooks;
    @SuppressWarnings("unused")
	private Vector<Book> mPopularBooks;

    private MainScreen mMainScreen;

    /** Creates new form FeaturedBookPanel */
    public FeaturedBookPanel() {
        initComponents();
    }

    public FeaturedBookPanel(MainScreen mMainScreen)
    {
        this.mMainScreen = mMainScreen;

        initComponents();
    }

    public void refreshLists()
    {
        FeaturedTabThread t = new FeaturedTabThread(this);
        t.start();
    }

    public void displayBookLists(Vector<Book> mRecentBooks, Vector<Book> mPopularBooks)
    {
        this.mRecentBooks = mRecentBooks;
        this.mPopularBooks = mPopularBooks;

        blpRecent.setBooks(mRecentBooks);
        blpPopular.setBooks(mPopularBooks);

        this.revalidate();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblRecent = new javax.swing.JLabel();
        scrRecent = new javax.swing.JScrollPane();
        blpRecent = new org.libarae.client.BookListPanel(mMainScreen);
        lblPopular = new javax.swing.JLabel();
        scrPopular = new javax.swing.JScrollPane();
        blpPopular = new org.libarae.client.BookListPanel(mMainScreen);

        lblRecent.setText("Recent");

        scrRecent.setViewportView(blpRecent);

        lblPopular.setText("Popular");

        scrPopular.setViewportView(blpPopular);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblPopular)
                    .addComponent(lblRecent)
                    .addComponent(scrRecent, javax.swing.GroupLayout.DEFAULT_SIZE, 479, Short.MAX_VALUE)
                    .addComponent(scrPopular, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 479, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblRecent)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(scrRecent, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblPopular)
                .addGap(18, 18, 18)
                .addComponent(scrPopular, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
                .addGap(22, 22, 22))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.libarae.client.BookListPanel blpPopular;
    private org.libarae.client.BookListPanel blpRecent;
    private javax.swing.JLabel lblPopular;
    private javax.swing.JLabel lblRecent;
    private javax.swing.JScrollPane scrPopular;
    private javax.swing.JScrollPane scrRecent;
    // End of variables declaration//GEN-END:variables

}
